## 11.5. Edit Commands

Recall that c, d, and y are the basic editing operators.

### 11.5.1. Inserting New Text

Command | Action
--- | ---
`a` | Append after cursor.
`A` | Append to end of line.
`i` | Insert before cursor.
`I` | Insert at beginning of line.
`o` | Open a line below cursor.
`O` | Open a line above cursor.
Esc | Terminate insert mode.
Tab | Insert a tab.
Backspace | Delete previous character (in insert mode).
Ctrl-I | Insert a tab.
Ctrl-U | Delete current line.
Ctrl-V | Insert next character verbatim.
Ctrl-[ | Terminate insert mode.

Some of the control characters listed in the previous table are set by stty. Your terminal settings may differ.

### 11.5.2. Changing and Deleting Text

The following table is not exhaustive but illustrates the most common operations.

Command | Action
--- | ---
`cw` | Change through end of current word.
`cc` | Change line.
`c$` | Change text from current position to end-of-line.
`C` | Same as c$.
`dd` | Delete current line.
`d$` | Delete remainder of line.
`D` | Same as d$.
``n `dd` | Delete n lines.
`dw` | Delete a word.
`d}` | Delete up to next paragraph.
`d^` | Delete back to beginning of line.
`d/`pattern | Delete up to first occurrence of pattern.
`dn` | Delete up to next occurrence of pattern.
`df` a | Delete up to and including a on current line.
`dt` a | Delete up to (not including) a on current line.
`dL` | Delete up to last line on screen.
`dG` | Delete to end-of-file.
`p` | Insert last deleted text after cursor.
`P` | Insert last deleted text before cursor.
`r` x | Replace character with x.
`R` text | Replace text beginning at cursor.
`s` | Substitute character.
``n `s` | Substitute n characters.
`S` | Substitute entire line.
`u` | Undo last change.
`U` | Restore current line.
`x` | Delete current character.
`X` | Delete back one character.
``n `X` | Delete previous n characters.
`.` | Repeat last change.
`~` | Reverse case.
`&` | Repeat last substitution.
`Y` | Copy (yank) current line to temporary buffer.
`yy` | Same as Y.
`"`x `yy` | Copy current line to buffer x.
`ye` | Copy text to end of word into temporary buffer.
`yw` | Same as ye.
`y$` | Copy rest of line into temporary buffer.
`"`x `dd` | Delete current line into buffer x.
`"`X `dd` | Delete current line and append to buffer x.
`"`x `p` | Put contents of buffer x.
`J` | Join previous line to current line.
`:j!` | Same as `J`.

Copyright © 2001 O'Reilly & Associates. All rights reserved.